<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1-toFixed() 保留小数点几位
      // 返回的是字符串
      var price = 123.45678
      console.log(price.toFixed(2)) //123.46

      //2- Math 对象
      //(1)-random 0-1  随机数
      console.log(Math.random())

      //(2)-round 四舍五入
      console.log(Math.round(4.64)) //5
      console.log(Math.round(4.46)) //4

      //(3)-ceil 向上取整 floor 向下取整
      console.log(Math.ceil(4.46)) //5
      console.log(Math.floor(4.46)) //4

      //(4)-abs 绝对值
      console.log(Math.abs(-10.2)) //10.2

      //(5)-sqrt 平方根
      console.log(Math.abs(10)) //100

      //(6)-pow(底数，指数) 次幂
      console.log(Math.pow(2, 3)) //8

      //(7)-max() 最大值 多个参数
      console.log(Math.max(10, 34, 20, 33, 7)) //34

      //(8)-min() 最小值 多个参数
      console.log(Math.min(10, 34, 20, 33, 7)) //7

      //(9)-PI 圆周率
      console.log(Math.PI)
    </script>
  </body>
</html>
